package D1104;

import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.CoolBar;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Button;

public class MyDialog extends Dialog {

	protected Object result;
	protected Shell shell;
	private Text text;
	private Text text_1;

	/**
	 * Create the dialog.
	 * @param parent
	 * @param style
	 */
	public MyDialog(Shell parent, int style) {
		super(parent, style);
		setText("SWT Dialog");
	}

	/**
	 * Open the dialog.
	 * @return the result
	 */
	public Object open() {
		createContents();
		shell.open();
		shell.layout();
		Display display = getParent().getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return result;
	}

	/**
	 * Create contents of the dialog.
	 */
	private void createContents() {
		shell = new Shell(getParent(), getStyle());
		shell.setSize(450, 300);
		shell.setText(getText());
		shell.setLayout(new FormLayout());
		
		Label label = new Label(shell, SWT.NONE);
		FormData fd_label = new FormData();
		fd_label.top = new FormAttachment(0, 10);
		fd_label.left = new FormAttachment(0, 27);
		label.setLayoutData(fd_label);
		label.setText("账号：");
		
		Label label_1 = new Label(shell, SWT.NONE);
		FormData fd_label_1 = new FormData();
		fd_label_1.top = new FormAttachment(label, 11);
		fd_label_1.left = new FormAttachment(label, 0, SWT.LEFT);
		label_1.setLayoutData(fd_label_1);
		label_1.setText("密码：");
		
		text = new Text(shell, SWT.BORDER);
		FormData fd_text = new FormData();
		fd_text.top = new FormAttachment(label, 0, SWT.TOP);
		fd_text.left = new FormAttachment(label, 16);
		text.setLayoutData(fd_text);
		
		text_1 = new Text(shell, SWT.BORDER);
		FormData fd_text_1 = new FormData();
		fd_text_1.top = new FormAttachment(label_1, 0, SWT.TOP);
		fd_text_1.right = new FormAttachment(text, 0, SWT.RIGHT);
		text_1.setLayoutData(fd_text_1);
		
		Label label_2 = new Label(shell, SWT.NONE);
		FormData fd_label_2 = new FormData();
		fd_label_2.top = new FormAttachment(text_1, 14);
		fd_label_2.left = new FormAttachment(label, 0, SWT.LEFT);
		label_2.setLayoutData(fd_label_2);
		label_2.setText("学历：");
		
		Button btnRadioButton = new Button(shell, SWT.RADIO);
		FormData fd_btnRadioButton = new FormData();
		fd_btnRadioButton.bottom = new FormAttachment(label_2, 0, SWT.BOTTOM);
		fd_btnRadioButton.left = new FormAttachment(text, 0, SWT.LEFT);
		btnRadioButton.setLayoutData(fd_btnRadioButton);
		btnRadioButton.setText("高中");
		
		Button button = new Button(shell, SWT.RADIO);
		FormData fd_button = new FormData();
		fd_button.bottom = new FormAttachment(label_2, 0, SWT.BOTTOM);
		fd_button.left = new FormAttachment(btnRadioButton, 6);
		button.setLayoutData(fd_button);
		button.setText("大专");
		
		Button button_1 = new Button(shell, SWT.RADIO);
		FormData fd_button_1 = new FormData();
		fd_button_1.top = new FormAttachment(label_2, 0, SWT.TOP);
		fd_button_1.left = new FormAttachment(button, 6);
		button_1.setLayoutData(fd_button_1);
		button_1.setText("本科");

	}
}
